//
//  RootViewController.m
//  The car
//
//  Created by 赵洋 on 14/11/18.
//  Copyright (c) 2014年 赵洋. All rights reserved.
//

#import "RootViewController.h"
#import "CustomCollection.h"
#import "Connection.h"
#import "CollectionModel.h"
@interface RootViewController ()<UICollectionViewDataSource, UICollectionViewDelegate>

@end

@implementation RootViewController
- (void)dealloc
{
    [_array release];
    [_mycollectionview release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.array = [NSMutableArray arrayWithObjects:Firsturl, secondurl, threeurl, foururl, fiveurl, sixurl, sevenurl, eighturl, nineurl, tenurl, elevenurl, twiveurl, thirdurl, nil];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    [self creatCollectionView];
    
    
}


- (void)creatCollectionView
{
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    [layout setScrollDirection:UICollectionViewScrollDirectionHorizontal];
    self.mycollectionview = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) collectionViewLayout:layout];
    [layout setItemSize:CGSizeMake(_mycollectionview.frame.size.width, _mycollectionview.frame.size.height - 113)];

    _mycollectionview.dataSource = self;
    _mycollectionview.delegate = self;
    [_mycollectionview registerClass:[CustomCollection class] forCellWithReuseIdentifier:@"ok"];
    [_mycollectionview setPagingEnabled:YES];
    [_mycollectionview setBackgroundColor:[UIColor whiteColor]];
    [_mycollectionview setShowsHorizontalScrollIndicator:NO];
    [self.view addSubview:_mycollectionview];
    [_mycollectionview release];
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return [_array count];
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    CustomCollection *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"ok" forIndexPath:indexPath];
    NSString *url = [_array objectAtIndex:indexPath.item];
    cell.url = url;
    return cell;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
